home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Information / CSMP Digest / volume 2 / csmp-v2-004.txt < prev    next >
Text File  |  1995-06-30  |  34KB  |  981 lines

  1. C.S.M.P. Digest             Thu, 14 Jan 93       Volume 2 : Issue 4
  2.  
  3. Today's Topics:
  4.  
  5.     Unlocking a locked volume
  6.     How do you draw a circle/oval?
  7.     Fun with WaitNextEvent
  8.     Getting StructureRegion of a dialog. etco
  9.     InsertMenuItem Nasties
  10.  
  11.  
  12.  
  13. The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
  14.  
  15. The digest is a collection of article threads from the internet newsgroup
  16. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  17. regularly and want an archive of the discussions.  If you don't know what a
  18. newsgroup is, you probably don't have access to it.  Ask your systems
  19. administrator(s) for details.  If you don't have access to news, there is
  20. no way that I know of for you to post articles to the group.
  21.  
  22. Each issue of the digest contains one or more sets of articles (called
  23. threads), with each set corresponding to a 'discussion' of a particular
  24. subject.  The articles are not edited; all articles included in this digest
  25. are in their original posted form (as received by our news server at
  26. cs.uoregon.edu).  Article threads are not added to the digest until the last
  27. article added to the thread is at least one month old (this is to ensure that
  28. the thread is dead before adding it to the digest).  Article threads that
  29. consist of only one message are generally not included in the digest.
  30.  
  31. The entire digest is available for anonymous ftp from ftp.cs.uoregon.edu
  32. [128.223.8.8] in the directory /pub/mac/csmp-digest.  Be sure to read the
  33. file /pub/mac/csmp-digest/README before downloading any files.  The most
  34. recent issues are available from sumex-aim.stanford.edu [36.44.0.6] in the
  35. directory /info-mac/digest/csmp.  If you don't have ftp capability, the sumex
  36. archive has a mail server; send a message with the text '$MACarch help' (no
  37. quotes) to LISTSERV@ricevm1.rice.edu for more information.
  38.  
  39. The digest is also available via email.  Just send a note saying that you
  40. want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
  41. automatically receive each new issue as it is created.  Sorry, back issues
  42. are not available through the mailing list.
  43.  
  44. Send administrative mail to mkelly@cs.uoregon.edu.
  45.  
  46.  
  47. -------------------------------------------------------
  48.  
  49. From: cmcclary@ucs.indiana.edu (Charles McClary)
  50. Subject: Unlocking a locked volume
  51. Organization: Indiana University
  52. Date: Thu, 10 Dec 1992 20:27:42 GMT
  53.  
  54. I assumed, from reading Inside Mac and Think Reference, that logically 
  55. unlocking a logically locked volume would be as simple as:
  56.  
  57. void unlock()
  58. {
  59.     HVolumeParam    pb;
  60.     OSErr            osErr;
  61.     Str255            volumeName;
  62.     SysEnvRec        SysEnvData;
  63.     
  64.     osErr = SysEnvirons(1, &SysEnvData);
  65.     
  66.     pb.ioVRefNum = SysEnvData.sysVRefNum; /* use startup drive */
  67.     pb.ioVolIndex = 0;
  68.     pb.ioNamePtr = volumeName;
  69.     pb.ioCompletion = nil;
  70.     
  71.     osErr = PBHGetVInfo(&pb, false); /* get volume info */
  72.     if (osErr == noErr)
  73.     {
  74.         pb.ioVAtrb &= 0x7FFF; /* set unlock volume bit */
  75.         osErr = PBSetVInfo(&pb, false); 
  76.         osErr = FlushVol(0, pb.ioVRefNum);
  77.     }
  78. }
  79.  
  80. However, the PBSetVInfo receives a -46 (vLckedErr - Volume is locked),
  81. which 
  82. makes some sense.  What am I missing to correct this?
  83.  
  84. Thanks in advance,
  85.  
  86. Charles McClary
  87. Indiana University
  88. cmcclary@indiana.edu
  89.  
  90. +++++++++++++++++++++++++++
  91.  
  92. From: absurd@apple.apple.com (Tim Dierks, software saboteur)
  93. Date: 10 Dec 92 22:22:48 GMT
  94. Organization: MacDTS Marauders
  95.  
  96. In article <cmcclary-101292152155@mcclary-mac.ucs.indiana.edu>,
  97. cmcclary@ucs.indiana.edu (Charles McClary) wrote:
  98. > I assumed, from reading Inside Mac and Think Reference, that logically 
  99. > unlocking a logically locked volume would be as simple as:
  100. > void unlock()
  101. > {
  102. >     HVolumeParam    pb;
  103. >     OSErr            osErr;
  104. >     Str255            volumeName;
  105. >     SysEnvRec        SysEnvData;
  106. >     
  107. >     osErr = SysEnvirons(1, &SysEnvData);
  108. >     
  109. >     pb.ioVRefNum = SysEnvData.sysVRefNum; /* use startup drive */
  110. >     pb.ioVolIndex = 0;
  111. >     pb.ioNamePtr = volumeName;
  112. >     pb.ioCompletion = nil;
  113. >     
  114. >     osErr = PBHGetVInfo(&pb, false); /* get volume info */
  115. >     if (osErr == noErr)
  116. >     {
  117. >         pb.ioVAtrb &= 0x7FFF; /* set unlock volume bit */
  118. >         osErr = PBSetVInfo(&pb, false); 
  119. >         osErr = FlushVol(0, pb.ioVRefNum);
  120. >     }
  121. > }
  122. > However, the PBSetVInfo receives a -46 (vLckedErr - Volume is locked),
  123. > which 
  124. > makes some sense.  What am I missing to correct this?
  125. > Thanks in advance,
  126. > Charles McClary
  127. > Indiana University
  128. > cmcclary@indiana.edu
  129.  
  130. Isn't it great?  There's no standard way to unlock a software-locked
  131. volume!  The only thing you can do is change the bit manually in the
  132. volume's entry in the VCB queue, then call _SetVolInfo to make sure
  133. it gets flushed out to the disk itself.
  134.  
  135. Fun, huh?
  136.  
  137. Tim Dierks
  138. MacDTS.  A rose by any other name, Keith.
  139.  
  140. +++++++++++++++++++++++++++
  141.  
  142. From: grobbins@Apple.COM (Grobbins)
  143. Date: 11 Dec 92 00:30:20 GMT
  144. Organization: Experimental Stuff at Apple
  145.  
  146. In article <absurd-101292142216@seuss.apple.com> absurd@apple.apple.com (Tim Dierks, software saboteur) writes:
  147. >Isn't it great?  There's no standard way to unlock a software-locked
  148. >volume!  The only thing you can do is change the bit manually in the
  149. >volume's entry in the VCB queue, then call _SetVolInfo to make sure
  150. >it gets flushed out to the disk itself.  Fun, huh?
  151.  
  152. No, not fun; it's a bit of a pain.  Sample code for unlocking a
  153. volume is available in the Volume Handling Q&As (available via
  154. anonymouse ftp from ftp.apple.com in the /dts/mac/tn/files directory.)
  155.  
  156. Grobbins         grobbins@apple.com
  157.  
  158. Usual disclaimers apply.
  159.  
  160. +++++++++++++++++++++++++++
  161.  
  162. From: lkimes@alshain.usc.edu (Lance 'Moof' Kimes)
  163. Date: 11 Dec 92 04:03:22 GMT
  164. Organization: University of Southern California, Los Angeles, CA
  165.  
  166.  
  167. In article <cmcclary-101292152155@mcclary-mac.ucs.indiana.edu>, cmcclary@ucs.indiana.edu (Charles McClary) writes:
  168. |> I assumed, from reading Inside Mac and Think Reference, that logically 
  169. |> unlocking a logically locked volume would be as simple as:
  170. |> 
  171. |> void unlock()
  172. |> {
  173. |>     HVolumeParam    pb;
  174. |>     OSErr            osErr;
  175. |>     Str255            volumeName;
  176. |>     SysEnvRec        SysEnvData;
  177. |>     
  178. |>     osErr = SysEnvirons(1, &SysEnvData);
  179. |>     
  180. |>     pb.ioVRefNum = SysEnvData.sysVRefNum; /* use startup drive */
  181. |>     pb.ioVolIndex = 0;
  182. |>     pb.ioNamePtr = volumeName;
  183. |>     pb.ioCompletion = nil;
  184. |>     
  185. |>     osErr = PBHGetVInfo(&pb, false); /* get volume info */
  186. |>     if (osErr == noErr)
  187. |>     {
  188. |>         pb.ioVAtrb &= 0x7FFF; /* set unlock volume bit */
  189. |>         osErr = PBSetVInfo(&pb, false); 
  190. |>         osErr = FlushVol(0, pb.ioVRefNum);
  191. |>     }
  192. |> }
  193. |> 
  194. |> However, the PBSetVInfo receives a -46 (vLckedErr - Volume is locked),
  195. |> which 
  196. |> makes some sense.  What am I missing to correct this?
  197. |> 
  198. |> Thanks in advance,
  199. |> 
  200. |> Charles McClary
  201. |> Indiana University
  202. |> cmcclary@indiana.edu
  203.  
  204.  
  205. Here is some code I wrote awhile back.
  206.  
  207. OSErr UnlockHD( short targetVRefNum)
  208. {
  209.         OSErr           Err;
  210.         QHdrPtr         VCBQHdrPtr;
  211.         VCB                     *ssvcb;
  212.  
  213.         Err = nsvErr;
  214.         VCBQHdrPtr = GetVCBQHdr();
  215.         ssvcb = (VCB *)VCBQHdrPtr->qHead;
  216.  
  217.         while((ssvcb != nil) && (ssvcb->vcbVRefNum != targetVRefNum))
  218.                 ssvcb = (VCB *)ssvcb->qLink;
  219.  
  220.         if (ssvcb->vcbVRefNum == targetVRefNum)
  221.         {
  222.                 if (!BitTst( &ssvcb->vcbAtrb, 0))
  223.                         return 0;
  224.                 BitClr( &ssvcb->vcbAtrb, 0);
  225.                 Err = FlushVol( nil, targetVRefNum);
  226.         }
  227.         return (Err);
  228. }
  229.  
  230. It perfectly. Have fun.
  231.  
  232.  
  233. Lance Kimes
  234. Systems Programmer
  235.  
  236. ---------------------------
  237.  
  238. From: mxmora@unix.sri.com (Matthew Xavier Mora)
  239. Subject: How do you draw a circle/oval?
  240. Date: 10 Dec 92 23:41:23 GMT
  241. Organization: SRI International
  242.  
  243. Does anybody have code that calculates what pixels to set to draw an 
  244. oval/circle given a rectangle/square not using quickdraw? Filled ovals
  245. would be nice also.
  246.  
  247. I need this for my ascii paint program. I got lines and rectangles working
  248. alrady, I would just like to include ovals in the program too.
  249.  
  250. Thanks,
  251. Xavier
  252.  
  253.  
  254. - ----------------------------------------------------------------------
  255. Matthew Xavier Mora                                mxmora@unix.sri.com
  256. SRI International                                       (415) 859-5011
  257. (signing Xavier because there are too many Matt's on the net :-))
  258. - ----------------------------------------------------------------------
  259.  
  260. +++++++++++++++++++++++++++
  261.  
  262. From: bwilliam@iat.holonet.net (Bill Williams)
  263. Organization: HoloNet National Internet Access BBS: 510-704-1058/modem
  264. Date: Sat, 12 Dec 1992 04:34:04 GMT
  265.  
  266.  
  267. /*=********************************************************************=*/
  268.  
  269.  
  270. /*=********************************************************************=*/
  271. #define INTEGER_32 long int
  272.  
  273. static void Draw_Filled_Ellipse_Primitive(INTEGER_32 start_X
  274. , INTEGER_32 start_Y
  275.                         ,INTEGER_32 axis_A, INTEGER_32 axis_B
  276.                         , PixPatHandle current_Pattern)
  277. {
  278. register INTEGER_32     active_X, active_Y;
  279. register INTEGER_32     axis_A_Squared, axis_B_Squared,
  280. axis_A_Squared_Times_2;
  281. register INTEGER_32     axis_B_Squared_Times_2, derivitive_X,
  282. derivitive_Y, dd;
  283.  
  284. /* END VAR */
  285.    /*=--------------------------------------------------------------------=*/
  286.    /*   Uses dual differential high efficiency technique    */
  287.    /*=--------------------------------------------------------------------=*/
  288.  
  289.    active_X = axis_A;
  290.    active_Y = 0;
  291.    axis_A_Squared = axis_A*axis_A;
  292.    axis_B_Squared = axis_B*axis_B;
  293.    axis_A_Squared_Times_2 = axis_A_Squared + axis_A_Squared;
  294.    axis_B_Squared_Times_2 = axis_B_Squared + axis_B_Squared;
  295.    derivitive_X = axis_B_Squared_Times_2*axis_A;
  296.    derivitive_Y = 0L;
  297.    dd = (axis_B_Squared / 4L) - (axis_B_Squared * axis_A) + axis_A_Squared;
  298.    
  299.    /*=--------------------------------------------------------------------=*/
  300.    /*   Step along Y axis    */
  301.    /*=--------------------------------------------------------------------=*/
  302.    while ( derivitive_X > derivitive_Y ) {
  303.       Draw_Patterned_Eastward_Line_Subprimitive(
  304.                (start_X - active_X)
  305.                , (start_Y - active_Y)
  306.                , (active_X << 1) +1);
  307.  
  308.       Draw_Patterned_Eastward_Line_Subprimitive(
  309.               (start_X - active_X)
  310.               ,(start_Y + active_Y)
  311.               , (active_X << 1) +1);
  312.  
  313.       active_Y +=1;
  314.       derivitive_Y += axis_A_Squared_Times_2;
  315.       if (dd <= 0L )
  316.          dd  += (derivitive_Y + axis_A_Squared);
  317.       else {
  318.          derivitive_X -= axis_B_Squared_Times_2;
  319.          active_X -= 1L;
  320.          dd += (derivitive_Y + axis_A_Squared - derivitive_X );
  321.       }
  322.    } /* while ( derivitive_X > derivitive_Y ) */
  323.    
  324.    /*=--------------------------------------------------------------------=*/
  325.    /*   Step along X axis    */
  326.    /*=--------------------------------------------------------------------=*/
  327.    
  328.    dd += ( ( ((3L *(axis_B_Squared-axis_A_Squared)) / 2L) 
  329.              - ( derivitive_X + derivitive_Y ) ) / 2L);
  330.    
  331.    while ( active_X > 0L ) {
  332.       Draw_Patterned_Eastward_Line_Subprimitive(
  333.           (start_X - active_X),(start_Y - active_Y), (active_X << 1) +1);
  334.  
  335.       Draw_Patterned_Eastward_Line_Subprimitive(
  336.          (start_X - active_X),(start_Y + active_Y), (active_X << 1) +1);
  337.  
  338.       active_X -=1;
  339.       derivitive_X -= axis_B_Squared_Times_2;
  340.       
  341.       if (dd > 0L )
  342.          dd  += (axis_B_Squared - derivitive_X);
  343.       else {
  344.          derivitive_Y += axis_A_Squared_Times_2;
  345.          active_Y += 1L;
  346.          dd += (derivitive_Y + axis_B_Squared - derivitive_X );
  347.       }
  348.    } /* while ( active_X > 0L ) */
  349.  
  350.    while (active_Y <= axis_B) {
  351.  
  352.       Draw_Patterned_Eastward_Line_Subprimitive(start_X
  353.          ,(start_Y + active_Y)
  354.           , 1L); /* actually only one pixel */
  355.  
  356.       Draw_Patterned_Eastward_Line_Subprimitive(start_X
  357.                 ,(start_Y - active_Y)
  358.                 , 1L);  /* actually only one pixel */
  359.  
  360.       active_Y += 1L;
  361.    }     
  362. } /* Draw_Filled_Ellipse_Primitive */
  363. /*=********************************************************************=*/
  364.  
  365.  
  366. /*=********************************************************************=*/
  367.  
  368.  
  369. I Guarantee this puppy is FAAAAST. I designed it from various sources.
  370.  
  371. (Draw_Patterned_Eastward_Line_Subprimitive should be written as fast as
  372. you can make it.... or just make it a LineTo.)
  373.  
  374.  
  375. Enjoy.
  376.  
  377. Bill Williams
  378.  
  379.  
  380. ---------------------------
  381.  
  382. From: bobert@informix.com (Robert Murphy)
  383. Subject: Fun with WaitNextEvent
  384. Date: 8 Dec 92 01:29:40 GMT
  385. Organization: Informix Software, Inc.
  386.  
  387. Today's Strange Factoid: WaitNextEvent appears to require QuickDraw
  388. and/or some of the managers to be initialized.  This is not documented
  389. in any of the references I have immediately available.
  390.  
  391. I haven't done any experiments to determine exactly *which* managers have
  392. to be initialized, and probably won't, although if someone knows I'd love
  393. to hear.
  394.  
  395. Bob Murphy
  396. ShadeTree Productions
  397. Doing an onsite contract at Informix, which is why I have a paucity of
  398. references.
  399.  
  400. +++++++++++++++++++++++++++
  401.  
  402. From: dougm@cns.caltech.edu (Doug McNaught)
  403. Date: 7 Dec 92 23:03:37
  404. Organization: The Sinister Icy Black Hand of Death Club
  405.  
  406. In article <bobert.723778180@godzilla> bobert@informix.com (Robert Murphy) writes:
  407.  
  408.    Today's Strange Factoid: WaitNextEvent appears to require QuickDraw
  409.    and/or some of the managers to be initialized.  This is not documented
  410.    in any of the references I have immediately available.
  411.  
  412.   Well, one of its arguments *is* a region...
  413. [explains the QD requirement, at least]
  414. - -doug
  415. - --
  416. Doug McNaught              |"When you start ruling out ideas merely because 
  417. dougm@cns.caltech.edu      | they are sheer, gibbering lunacy, you've stopped
  418. doug@midget.towson.edu     | doing science." -Robert Firth in sci.physics
  419.   Nobody approves my opinions! Not even me, sometimes. Read at your own risk.
  420.  
  421. +++++++++++++++++++++++++++
  422.  
  423. From: nerm@apple.com (Dean Yu)
  424. Date: 8 Dec 92 18:25:28 GMT
  425. Organization: Apple Computer, Inc.
  426.  
  427. In article <bobert.723778180@godzilla>, bobert@informix.com (Robert Murphy)
  428. wrote:
  429. > Today's Strange Factoid: WaitNextEvent appears to require QuickDraw
  430. > and/or some of the managers to be initialized.  This is not documented
  431. > in any of the references I have immediately available.
  432. > I haven't done any experiments to determine exactly *which* managers have
  433. > to be initialized, and probably won't, although if someone knows I'd love
  434. > to hear.
  435. > Bob Murphy
  436. > ShadeTree Productions
  437. > Doing an onsite contract at Informix, which is why I have a paucity of
  438. > references.
  439.  
  440.   Well, WaitNextEvent is part of the Event Manager, and to use the Event
  441. Manager, you need to initialize the Window Manager, and to do that, you
  442. have to initialize QuickDraw and the Font Manager...  Seems perfectly
  443. logical to me...
  444.  
  445. - -- Dean Yu
  446.    Blue Meanie, Negative Ethnic Role Model, etc.
  447.    Apple Computer, Inc.
  448.  
  449. +++++++++++++++++++++++++++
  450.  
  451. From: d88-jwa@dront.nada.kth.se (Jon Wtte)
  452. Date: 9 Dec 92 10:07:15 GMT
  453. Organization: Royal Institute of Technology, Stockholm, Sweden
  454.  
  455. In <nerm-081292102455@90.10.20.86> nerm@apple.com (Dean Yu) writes:
  456.  
  457. >  Well, WaitNextEvent is part of the Event Manager, and to use the Event
  458. >Manager, you need to initialize the Window Manager, and to do that, you
  459. >have to initialize QuickDraw and the Font Manager...  Seems perfectly
  460. >logical to me...
  461.  
  462. Does this mean a Faceless Background App should call
  463.     InitGraf ( &qd . thePort ) ;
  464.     InitFonts ( ) ;
  465.     InitWindows ( ) ;
  466.  
  467. just to call WaitNextEvent? Seems illogical to me.
  468.  
  469. Cheers,
  470.  
  471.                             / h+
  472.  
  473. - -- 
  474.  -- Jon W{tte, h+@nada.kth.se, Mac Hacker Deluxe --
  475.    This signature is kept shorter than 4 lines in the interests of UseNet
  476.    S/N ratio.
  477.  
  478. +++++++++++++++++++++++++++
  479.  
  480. From: chh9@ellis.uchicago.edu (Conrad Halling)
  481. Date: 9 Dec 92 16:40:03 GMT
  482. Organization: University of Chicago Computing Organizations
  483.  
  484. In article <bobert.723778180@godzilla> 
  485.      bobert@informix.com (Robert Murphy) writes:
  486.  
  487. >Today's Strange Factoid: WaitNextEvent appears to require QuickDraw
  488. >and/or some of the managers to be initialized.  This is not documented
  489. >in any of the references I have immediately available.
  490.  
  491. >From Inside Macintosh, Volume I, p. 255:
  492.  
  493.      "Before using the Event Manager, you should initialize the Window
  494. Manager by calling its procedure InitWindows; parts of the Event Manager
  495. rely on the Window Manager's data structures and will not work properly
  496. unless those structures have been properly initialized.  Initializing
  497. the Window Manager requires you to have initialized QuickDraw and
  498. the Font Manager.
  499.      "Assembly-language note:  If you want to use events but not windows,
  500. set the global variable WindowList (a long word) to 0 instead of calling
  501. InitWindows."
  502.  
  503.  
  504. - -- 
  505. Conrad Halling
  506. c-halling@uchicago.edu
  507.  
  508. +++++++++++++++++++++++++++
  509.  
  510. From: nerm@apple.com (Dean Yu)
  511. Date: Wed, 9 Dec 1992 20:04:12 GMT
  512. Organization: Apple Computer, Inc.
  513.  
  514. In article <1992Dec9.100715.28595@kth.se>, d88-jwa@dront.nada.kth.se (Jon
  515. Wtte) wrote:
  516. > In <nerm-081292102455@90.10.20.86> nerm@apple.com (Dean Yu) writes:
  517. > >  Well, WaitNextEvent is part of the Event Manager, and to use the Event
  518. > >Manager, you need to initialize the Window Manager, and to do that, you
  519. > >have to initialize QuickDraw and the Font Manager...  Seems perfectly
  520. > >logical to me...
  521. > Does this mean a Faceless Background App should call
  522. >     InitGraf ( &qd . thePort ) ;
  523. >     InitFonts ( ) ;
  524. >     InitWindows ( ) ;
  525. > just to call WaitNextEvent? Seems illogical to me.
  526. > Cheers,
  527. >                             / h+
  528.   You can get away with not calling InitWindows() by slamming 0 into the
  529. WindowList low memory global.  This is mentioned in the Event Manager
  530. chapter of Inside Mac I.
  531.  
  532. - -- Dean Yu
  533.    Blue Meanie, Negative Ethnic Role Model, etc.
  534.    Apple Computer, Inc.
  535.  
  536. +++++++++++++++++++++++++++
  537.  
  538. From: falken@apple.com (Dave Falkenburg)
  539. Date: 9 Dec 92 21:14:16 GMT
  540. Organization: Apple Computer, Inc.
  541.  
  542. In article <nerm-091292120342@90.10.20.86> Dean Yu, nerm@apple.com writes:
  543. >> >  Well, WaitNextEvent is part of the Event Manager, and to use the
  544. Event
  545. >> >Manager, you need to initialize the Window Manager, and to do that,
  546. you
  547. >> >have to initialize QuickDraw and the Font Manager...  Seems perfectly
  548. >> >logical to me...
  549. >> 
  550. >> Does this mean a Faceless Background App should call
  551. >>     InitGraf ( &qd . thePort ) ;
  552. >>     InitFonts ( ) ;
  553. >>     InitWindows ( ) ;
  554. >> 
  555. >> just to call WaitNextEvent? Seems illogical to me.
  556. >> 
  557. >> Cheers,
  558. >> 
  559. >>                             / h+
  560. >> 
  561. >  You can get away with not calling InitWindows() by slamming 0 into the
  562. >WindowList low memory global.  This is mentioned in the Event Manager
  563. >chapter of Inside Mac I.
  564.  
  565. Please donnt call InitWindows() inside a faceless background app.
  566.  
  567. You still need to call InitGraf(), and InitFonts() because of 0(a5) and
  568. that region thing, and some TrueType font caching stuff.
  569.  
  570. - -Dave Falkenburg
  571. - -Apple Computer, Inc.
  572.  
  573. +++++++++++++++++++++++++++
  574.  
  575. From: Quinn <quinn@cs.uwa.edu.au>
  576. Organization: The University of Western Australia
  577. Date: Thu, 10 Dec 1992 01:07:40 GMT
  578.  
  579. In article <1992Dec9.100715.28595@kth.se> Jon Wtte,
  580. d88-jwa@dront.nada.kth.se writes:
  581. >Does this mean a Faceless Background App should call
  582. >    InitGraf ( &qd . thePort ) ;
  583. >    InitFonts ( ) ;
  584. >    InitWindows ( ) ;
  585.  
  586. It does have to call *InitGraf* at least under MultiFinder 6.
  587. MultiFinder has a cow if any application doesn't have a proper A5
  588. world including QD globals (yes even faceless background ones).
  589.  
  590. Exercise for the brave... get a copy of MultiFinder 6 and disassemble
  591. its _NMInstall patches.  Notice how MultiFinder samples the
  592. application's (A5) and puts it into MultiFinder's (A5).  Worry
  593. about what would happen if (A5) was not valid (ie you hadn't called
  594. InitGraf).
  595.  
  596. Quinn "The Eskimo!"      <quinn@cs.uwa.edu.au>     "Support HAVOC!"
  597. Department of Computer Science, The University of Western Australia
  598.   -- Who spent *days* debugging that one!
  599.  
  600. +++++++++++++++++++++++++++
  601.  
  602. From: d88-jwa@dront.nada.kth.se (Jon Wtte)
  603. Date: 9 Dec 92 21:59:47 GMT
  604. Organization: Royal Institute of Technology, Stockholm, Sweden
  605.  
  606. In <nerm-091292120342@90.10.20.86> nerm@apple.com (Dean Yu) writes:
  607.  
  608. >  You can get away with not calling InitWindows() by slamming 0 into the
  609. >WindowList low memory global.  This is mentioned in the Event Manager
  610. >chapter of Inside Mac I.
  611.  
  612. Ah, but I mistrust lo-mem globals by pure training.
  613.  
  614. Say, when a faceless app "mode" was added, why not a documented
  615. trap to do this without hassle? Just a suggestion...
  616.  
  617. Cheers,
  618.  
  619.                         / h+
  620.  
  621. - -- 
  622.  -- Jon W{tte, h+@nada.kth.se, Mac Hacker Deluxe --
  623.  
  624.    There's no problem that can't be solved using brute-force algorithms
  625.    and a sufficiently fast computer. Ergo, buy more hardware.
  626.  
  627. +++++++++++++++++++++++++++
  628.  
  629. From: mtc@henry.ece.cmu.edu (Magnetic Technology Center)
  630. Organization: Electrical and Computer Engineering, Carnegie Mellon
  631. Date: Thu, 10 Dec 1992 03:35:46 GMT
  632.  
  633. d88-jwa@dront.nada.kth.se (Jon Wtte) writes:
  634. >nerm@apple.com (Dean Yu) writes:
  635. >
  636. >>  Well, WaitNextEvent is part of the Event Manager, and to use the Event
  637. >>Manager, you need to initialize the Window Manager, and to do that, you
  638. >>have to initialize QuickDraw and the Font Manager...  Seems perfectly
  639. >>logical to me...
  640. >
  641. >Does this mean a Faceless Background App should call
  642. >    InitGraf ( &qd . thePort ) ;
  643. >    InitFonts ( ) ;
  644. >    InitWindows ( ) ;
  645. >
  646. >just to call WaitNextEvent? Seems illogical to me.
  647.  
  648. the above snippet _is_ illogical, in this case.  IM-I Event Manager
  649. covers this nicely.  here, initializing the window manager should be
  650. interpreted as setting WindowList to nil and not calling InitWindows()!
  651. then again, perhaps InitWindows() could check for FBO and do the right
  652. thing in that situation (adding even more system version dependences).
  653. apps.
  654.  
  655.   -dave-
  656. mtc@henry.ece.cmu.edu
  657.  
  658. +++++++++++++++++++++++++++
  659.  
  660. From: bobert@informix.com (Robert Murphy)
  661. Date: 11 Dec 92 01:24:01 GMT
  662. Organization: Informix Software, Inc.
  663.  
  664. d88-jwa@dront.nada.kth.se (Jon Wtte) writes:
  665.  
  666. >In <nerm-081292102455@90.10.20.86> nerm@apple.com (Dean Yu) writes:
  667.  
  668. >>  Well, WaitNextEvent is part of the Event Manager, and to use the Event
  669. >>Manager, you need to initialize the Window Manager, and to do that, you
  670. >>have to initialize QuickDraw and the Font Manager...  Seems perfectly
  671. >>logical to me...
  672.  
  673. >Does this mean a Faceless Background App should call
  674. >    InitGraf ( &qd . thePort ) ;
  675. >    InitFonts ( ) ;
  676. >    InitWindows ( ) ;
  677.  
  678. >just to call WaitNextEvent? Seems illogical to me.
  679.  
  680. Well, since I started this thread, I've been doing some digging around...
  681.  
  682. In a recent issue of Develop, there's an article on faceless background apps
  683. called "Be My Guest", in which C.K. Haun says:
  684.  
  685. >Writing an FBA is simple. An FBA is a subset of a standard Macintosh
  686. >application, consisting of a minimal event loop and the code to handle two
  687. >types of events, null events and high-level events. No other events are sent
  688. >to an FBA. This makes a great deal of sense, since every other event
  689. >(keystroke, mouse click, and such) is designed for foreground applications.
  690.  
  691.     <stuff deleted>
  692.  
  693. >As you can see, there's not much there. The first thing you'll notice is that
  694. >an FBA doesn't start up any managers. All the managers you normally start are
  695. >based on user interface actions. Thus, they should not  be called in an FBA-in
  696. >fact, calling them will cause your FBA to crash. There's one exception to this
  697. >rule: you can initialize QuickDraw, but only  to provide yourself with off-
  698. >screen grafPorts or to use some QuickDraw functions. Do not do any actual
  699. >screen drawing from an FBA.
  700.  
  701. So... according to this article, an FBA doesn't have to initialize any
  702. managers.  I presume this information is correct, so I guess maybe an app
  703. that doesn't have "background-only" set in the size resource is different
  704. from an FBA?
  705.  
  706. - - Bob Murphy
  707.  
  708. +++++++++++++++++++++++++++
  709.  
  710. From: grobbins@Apple.COM (Grobbins)
  711. Date: 12 Dec 92 22:48:50 GMT
  712. Organization: Experimental System Software Department
  713.  
  714. In article <bobert.724037041@godzilla> bobert@informix.com (Robert Murphy) writes:
  715. >In a recent issue of Develop, there's an article on faceless background apps
  716. >called "Be My Guest", in which C.K. Haun says: ...
  717. >
  718. >So... according to this article, an FBA doesn't have to initialize any
  719. >managers.  I presume this information is correct, so I guess maybe an app
  720. >that doesn't have "background-only" set in the size resource is different
  721. >from an FBA?
  722.  
  723. No, the article is not entirely correct.  A faceless background app
  724. (AKA background-only app) definitely should call InitGraf; indeed, any
  725. app which uses the Apple Event Manager should call InitGraf (since the
  726. Apple event manager uses QuickDraw's Random function.)  An FBA must have
  727. both the canBackground and backgroundOnly bits set; by definition,
  728. that makes it an FBA.
  729.  
  730. An upcoming tech note ("Background-Only Applications") will try to
  731. address gotchas of FBAs and correct and supplement the New Inside
  732. Macintosh information.  (Other gotchas:  the default stack for an FBA
  733. is only 2K; you cannot set an arbitrary stack, but rather SetApplLimit
  734. enforces a 24K minimum on color machines; routines which might
  735. sometimes raise dialogs can kill FBAs; launch order vis-a-vis the
  736. Finder is strange; use of the Notification Manager has HI implications
  737. because the user may not know the FBA is running.)  Sample code is
  738. available via anonymous ftp from ftp.apple.com (see
  739. /dts/mac/sc/snippets/interapp.comm/smalldaemon.hqx.)
  740.  
  741.  
  742. Grobbins           grobbins@apple.com
  743.  
  744. Usual disclaimers apply.
  745.  
  746. ---------------------------
  747.  
  748. From: ttak@quads.uchicago.edu (toki  takeuchi)
  749. Subject: Getting StructureRegion of a dialog. etco
  750. Date: 13 Dec 92 01:29:06 GMT
  751. Organization: University of Chicago Computing Organizations
  752.  
  753. I want to get the StructureRegion of a dialog before I display
  754. the dialog.  I.e., I want to get the rectangle of the entire
  755. window, including the window structure before the dialog is displayed.
  756.  
  757. I've tried getting the DialogPeek's structure region's boundary
  758. box for an invisible dialog (before the dialog is displayed, with
  759. the Initially Visible flag off in its DLOG resource), but
  760. until I call ShowWindow, its structure region's rect remains
  761. as (0,0,0,0).
  762.  
  763. I want to do this because I want to position a dialog in System 6
  764. according to the auto-position feature of System 7.  System 7
  765. seems to position the dialog depending on the rect of the
  766. WDEF and not the grafport portrect.  Anyone at Apple know the
  767. secret???
  768.  
  769. Thanks a lot!
  770.  
  771. Kenji Takeuchi (please respond directly, preferably).
  772.  
  773. +++++++++++++++++++++++++++
  774.  
  775. From: ttak@quads.uchicago.edu (toki  takeuchi)
  776. Organization: University of Chicago Computing Organizations
  777. Date: Sun, 13 Dec 1992 01:22:52 GMT
  778.  
  779.  
  780.  
  781. +++++++++++++++++++++++++++
  782.  
  783. From: absurd@apple.apple.com (Tim Dierks, software saboteur)
  784. Date: 13 Dec 92 22:30:12 GMT
  785. Organization: MacDTS Marauders
  786.  
  787. In article <1992Dec13.012906.18671@midway.uchicago.edu>,
  788. ttak@quads.uchicago.edu (toki  takeuchi) wrote:
  789. > I want to get the StructureRegion of a dialog before I display
  790. > the dialog.  I.e., I want to get the rectangle of the entire
  791. > window, including the window structure before the dialog is displayed.
  792. > I've tried getting the DialogPeek's structure region's boundary
  793. > box for an invisible dialog (before the dialog is displayed, with
  794. > the Initially Visible flag off in its DLOG resource), but
  795. > until I call ShowWindow, its structure region's rect remains
  796. > as (0,0,0,0).
  797. > I want to do this because I want to position a dialog in System 6
  798. > according to the auto-position feature of System 7.  System 7
  799. > seems to position the dialog depending on the rect of the
  800. > WDEF and not the grafport portrect.  Anyone at Apple know the
  801. > secret???
  802.  
  803. The structure region generally doesn't get calculated until you
  804. display the window.  You can get the WDEF to figure them out if
  805. you call it manually, but there's a better solution for this case;
  806. just move the dialog way off screen and display it behind the
  807. other windows (so you don't affect the highlighting of your
  808. windows); you can then examine the structure region, etc, so
  809. you can determine where to put your dialog.
  810.  
  811. > Kenji Takeuchi (please respond directly, preferably).
  812.  
  813. (I emailed this too.)
  814. (OK, well, not yet, but soon.)
  815.  
  816. Tim Dierks
  817. MacDTS, pinball addict
  818.  
  819. ---------------------------
  820.  
  821. From: duga@pacvax.UUCP (Brady Duga)
  822. Subject: InsertMenuItem Nasties
  823. Date: 10 Dec 92 20:53:58 GMT
  824. Organization: Pacer Software Inc., Westborough, MA USA
  825.  
  826. I don't think I've seen this question before (though my net access has been
  827. shaky recently), so here goes...
  828.  
  829. I want to add items to a menu that contain the "/" character. InsertMenuItem
  830. and AppendMenu parse this as meaning the next character is a command key
  831. equiv. But I don't want that. I want the character to appear. Does anyone
  832. have an idea how to work around this? I need to create the menu on the fly, so
  833. pre-creating it with ResEdit isn't a solution...
  834.  
  835. - --Brady (duga@pacersoft.com)
  836.  
  837.  
  838.  
  839. +++++++++++++++++++++++++++
  840.  
  841. From: absurd@apple.apple.com (Tim Dierks, software saboteur)
  842. Date: 10 Dec 92 22:57:01 GMT
  843. Organization: MacDTS Marauders
  844.  
  845. In article <1831@pacvax.UUCP>, duga@pacvax.UUCP (Brady Duga) wrote:
  846. > I don't think I've seen this question before (though my net access has been
  847. > shaky recently), so here goes...
  848. > I want to add items to a menu that contain the "/" character. InsertMenuItem
  849. > and AppendMenu parse this as meaning the next character is a command key
  850. > equiv. But I don't want that. I want the character to appear. Does anyone
  851. > have an idea how to work around this? I need to create the menu on the fly, so
  852. > pre-creating it with ResEdit isn't a solution...
  853. > --Brady (duga@pacersoft.com)
  854.  
  855. When you're dynamically creating menus, the safest way to do it is
  856. to append an innocuous menu item (such as "New Item"), then use
  857. SetItem() to change its text to the actual text you desire.  Because
  858. SetItem() doesn't parse the name for the metacharacters, you won't
  859. have the problem you're having.
  860.  
  861. A similar problem is that all strings starting with "-" will appear
  862. as dashed lines, rather than menu items.  Because this is actually
  863. done by the MDEF, it can't be worked around with SetItem; if you want
  864. the hyphen to appear as the first character, there are a couple of
  865. options; either change it to an en-dash, which looks pretty similar
  866. (character $D0, or type option-- (option-hyphen) or insert an invisible
  867. character before the hyphen to fool the MDEF.  A null character (hex
  868. $00) is good because it's blank and zero-width, but because it's used
  869. as the delimiter for C strings, you may need to be careful.
  870.  
  871. Tim Dierks
  872. MacDTS, but I speak for myself
  873.  
  874. +++++++++++++++++++++++++++
  875.  
  876. From: haynes@mace.cc.purdue.edu (Carl W. Haynes III)
  877. Date: 11 Dec 92 00:39:57 GMT
  878. Organization: Purdue University
  879.  
  880. In article <1831@pacvax.UUCP> duga@pacvax.UUCP (Brady Duga) writes:
  881. >I want to add items to a menu that contain the "/" character. InsertMenuItem
  882. >and AppendMenu parse this as meaning the next character is a command key
  883. >equiv. But I don't want that. I want the character to appear. Does anyone
  884. >have an idea how to work around this? I need to create the menu on the fly, so
  885. >pre-creating it with ResEdit isn't a solution...
  886.  
  887. SetItem doesn't interpret the special characters, so first AppendMenu with
  888. an empty string, then SetItem with your string:
  889.  
  890.      AppendMenu(menuHdl, "\p ");
  891.      SetItem(menuHdl, menuNum, menuStr);
  892.  
  893.  
  894. carl
  895.  
  896.  
  897. - --
  898. Carl W. Haynes III                    ||  hcs@applelink.apple.com
  899. Haynes Consulting Services            || haynes@mace.cc.purdue.edu 
  900. Macintosh Programming and Consulting  ||      ** AVAILABLE ** 
  901.  
  902. +++++++++++++++++++++++++++
  903.  
  904. From: jcav@ellis.uchicago.edu (JohnC)
  905. Date: 10 Dec 92 22:41:53 GMT
  906. Organization: The Royal Society for Putting Things on Top of Other Things
  907.  
  908. In article <1831@pacvax.UUCP> duga@pacvax.UUCP (Brady Duga) writes:
  909. >I want to add items to a menu that contain the "/" character. InsertMenuItem
  910. >and AppendMenu parse this as meaning the next character is a command key
  911. >equiv. But I don't want that. I want the character to appear. Does anyone
  912. >have an idea how to work around this? I need to create the menu on the fly, so
  913. >pre-creating it with ResEdit isn't a solution...
  914.  
  915.  
  916. Use _InsertMenuItem or _AppendMenu to create an item consisting only of the
  917. letter "x".  Then use _SetItem to change the text of this newly-created item
  918. from "x" to the item string you really wanted (containing meta-characters
  919. galore if you so desire).
  920.  
  921. - -- 
  922. John Cavallino                  |  EMail: jcav@midway.uchicago.edu
  923. University of Chicago Hospitals |         John_Cavallino@uchfm.bsd.uchicago.edu
  924. Office of Facilities Management | USMail: 5841 S. Maryland Ave, MC 0953
  925. B0 f++ c+ g++ k s++ e+ h- pv    |         Chicago, IL  60637
  926.  
  927. +++++++++++++++++++++++++++
  928.  
  929. From: keith@taligent.com (Keith Rollin)
  930. Organization: Taligent
  931. Date: Fri, 11 Dec 1992 01:00:54 GMT
  932.  
  933. In article <1831@pacvax.UUCP>, duga@pacvax.UUCP (Brady Duga) wrote:
  934. > I don't think I've seen this question before (though my net access has been
  935. > shaky recently), so here goes...
  936. > I want to add items to a menu that contain the "/" character. InsertMenuItem
  937. > and AppendMenu parse this as meaning the next character is a command key
  938. > equiv. But I don't want that. I want the character to appear. Does anyone
  939. > have an idea how to work around this? I need to create the menu on the fly, so
  940. > pre-creating it with ResEdit isn't a solution...
  941.  
  942. SetItem does not interpret the meta-characters. Therefore:
  943.  
  944.     AppendMenu(menuHandle, "dummy");
  945.     SetItem(menuHandle, CountMItems(menuHandle), "Real/Text");
  946.  
  947. Make sure that the string you pass to AppendMenu is not empty, or
  948. AppendMenu will ignore it.
  949.  
  950. - -----
  951. Keith Rollin
  952. Phantom Programmer
  953. Taligent, Inc.
  954.  
  955. ---------------------------
  956.  
  957. End of C.S.M.P. Digest
  958. **********************
  959.